﻿using System;
using System.Collections.Generic;
using Quartz;

namespace ZilLion.TaskManager.Core.Quartz
{
    public class CustomJobExecutionContext : IJobExecutionContext
    {
        private readonly IDictionary<object, object> data = new Dictionary<object, object>();
        public IScheduler Scheduler { get; }
        public ITrigger Trigger { get; }
        public ICalendar Calendar { get; }
        public bool Recovering { get; }
        public TriggerKey RecoveringTriggerKey { get; }
        public int RefireCount { get; }
        public JobDataMap MergedJobDataMap { get; }
        public IJobDetail JobDetail { get; set; }
        public IJob JobInstance { get; }
        public DateTimeOffset? FireTimeUtc { get; }
        public DateTimeOffset? ScheduledFireTimeUtc { get; }
        public DateTimeOffset? PreviousFireTimeUtc { get; }
        public DateTimeOffset? NextFireTimeUtc { get; }
        public string FireInstanceId { get; }
        public object Result { get; set; }
        public TimeSpan JobRunTime { get; }
        public void Put(object key, object objectValue)
        {
            data[key] = objectValue;
        }

        public object Get(object key)
        {
            object retValue;
            data.TryGetValue(key, out retValue);
            return retValue;
        }
    }
}